<?php 
	$this->load->view("partial/header");
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb" dir="ltr">
<head>
	<title>Print report</title>
	<style type="text/css">
	
	a{
		color:#0000FF;
		text-decoration:none;
	}
	#tbl_print_detail{
		font-size:11px;
	}
	#tbl_print_detail .comp_text, #tbl_print_detail .total_price{
		font-size:13px;		
	}
	.bold{
		font-weight:bold;
	}
	#order_detail{
		font-size: 10px;
	}
	#tbl_print_detail td{
		text-indent: 10px;
		padding-top:5px;
		padding-bottom:5px;
	}
	#tbl_print_detail td.title{
		text-indent: 10px;
		padding-top:0px !important;
		padding-bottom:0px !important;
	}
	#tbl_print_detail td.border{
		border:1px solid #000;
	}
	#tbl_print_detail td.top{
		border-top:none;
		border-left:1px solid #000;
		border-right:1px solid #000;
		border-bottom:1px solid #000;
	}
	#tbl_print_detail td.right{
		border-right:none;
		border-left:1px solid #000;
		border-top:1px solid #000;
		border-bottom:1px solid #000;
	}
	#tbl_print_detail td.bottom{
		border-bottom:none;
		border-left:1px solid #000;
		border-right:1px solid #000;
		border-top:1px solid #000;
	}
	#tbl_print_detail td.left{
		border-left : none ;
		border-top:1px solid #000;
		border-right:1px solid #000;
		border-bottom:1px solid #000;
	}
	
	#tbl_print_detail td.top_left{
		border-left:none;
		border-top:none;
		border-right:1px solid #000;
		border-bottom:1px solid #000;
	}
	
	#tbl_print_detail td.top_right{
		border-right:none;
		border-top:none;
		border-left:1px solid #000;
		border-bottom:1px solid #000;
	}
	
	#tbl_print_detail td.bottom_righ {
		border-right:none;
		border-bottom:none;
		border-left:1px solid #000;
		border-top:1px solid #000;
	}
	#tbl_print_detail td.bottom_left{
		border-left:none;
		border-top:1px solid #000;
		border-right:1px solid #000;
		border-bottom:none;
	}
	#tbl_print_detail td.right_left{
		border-left:none;
		border-top:1px solid #000;
		border-right:none;
		border-bottom:1px solid #000;
	}
	.a-right{
		text-align: right;
		padding-right:10px;
	}
	
	.a-center{
		text-align:center;
	}
	
	.a-left{
		text-align: left;
	}
	.f-left{
		float:left;
	}
	.f-right{
		float:right;
	}
	.left30{
		padding-left:30px;
	}
	.price{
		width:100px;
	}
	.problem{
		width:200px;
	}
	.stt{
		width:50px;
	}
	#tbl_print_detail td ol{
		padding-left:30px;
	}
	#tbl_print_detail .comp_text{
		text-indent:5px;
	}
	#tbl_print_detail .hr_td{
		height:3px;line-height:3px;
	}
	td.term_and_condition{
		font-size:9px;
	}
</style>
</head>	
<body onload="window.print();">
<center>
	<table id="tbl_print_detail">
		<!-- Logo -->
		<tr>
			<td class="border">
				<table>
					<tr>
						<td width="60" class="a-left">
							<?php 
							//echo $image = $this->Appconfig->get_logo_image();	
							echo img(array('src' => 'images/header/print_logo.png'));
							?>
							
						</td>
						<td class="a-left comp_text bold" >E-STORE</td>
					</tr>
				</table>
			</td>	
		</tr>
		<!-- End Logo -->
		<!-- ABN -->
		<?php if($type=='print_receipt'){?>
		<tr>
			<td align='center' class="border"><div id="sale_receipt">ABN : <?php echo $this->config->item('abn'); ?></div></td>
		</tr>
		<?php }?>
		<!-- End ABN -->
		<!-- ABN -->
		<tr>
			<td align='center' class="border bold">Service Receipt</td>
		</tr>
		<!-- End ABN -->
		<!-- Company info -->
		<tr>
			<td class="border" style="text-align:right;padding-right:10px;">
				<p>No : <?php echo $no ; ?></p>
				<p> <?php echo nl2br($this->config->item('address')); ?></p>
				<p>Ph/Mob : <?php echo $this->config->item('phone'); ?></p>
			</td>
		</tr>
		<!-- End Company info -->
		<!-- Customer info -->
		<tr>
			<td class="border">
				<?php 
					if(count($cart)!=0)
					{
						$customer_name =  $cart[0]['customer_name'];
						$customer_phone  =  $cart[0]['phone_num'];
					}
				?>
				<table>
					<tr>
						<td class="a-left">Customer</td>
						<td align='right' style="padding-right:10px;"><?php echo $customer_name ; ?></td>
					</tr>
					<tr>
						<td class="a-left">Ph/Mob :</td>
						<td align='right' style="padding-right:10px;"><?php echo $customer_phone ; ?></td>
					</tr>
				</table>
			</td>
		</tr>
		<!-- End Customer info -->
		<!-- Customer info -->
		<tr>
			<td class="border">
				<table>
					<tr>
						<td class="a-left">Staff</td>
						<td align='right' style="padding-right:10px;"><?php echo $user_info->first_name." ".$user_info->last_name ; ?></td>
					</tr>
					<tr>
						<td class="a-left">Date :</td>
						<td align='right' style="padding-right:10px;"><?php echo $transaction_time ; ?></td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
		<td class="border title">
			<table id="order_detail">
				
			<?php
				if(count($cart)==0)
				{
			?>
					<tr>
						<td colspan='2' style="height:60px;border:none;" class="border">
							<div class='warning_message' style='padding:7px;'><?php echo lang('services_no_items'); ?></div>
						</td>
					</tr>
			<?php
				}
				else
				{
					$stt = 1;
					$total_cost = 0;
					foreach($cart as $key=>$value)
					{
				?>
						<tr>
							<td class="a-left"><i>Brand</i> : <?php echo $value['product_brand']; ?></td>
						</tr>
						<tr>
							<td class="a-left"><i>Model</i> : <?php echo $value['product_model']; ?></td>
						</tr>
						<tr>		
							<td class="a-left"><i>Description</i> : <?php echo $value['problem_description']; ?></td>
						</tr>
						<tr>
							<td class="a-left"><i>Date Return</i> : 
							<?php 
								//echo $value['date_return']; 
								$list = explode('-',$value['date_return']);
								echo $list[2]."-".$list[1]."-".$list[0];
							?>
							</td>
						</tr>
						<tr>
							<td class="a-left"><i>Repaired Cost</i> : <?php $cost = $value['service_cost'] ; echo to_currency($cost) ; ?></td>
						</tr>
				<?php if(!empty($value['service_note'])){ ?>
						<tr>
							<td colspan="2" class="a-left">
								<i>Note </i>: <?php echo $value['service_note'] ; ?>
							</td>
						</tr>
					<?php } ?>	
					
					<?php 
						$serv_id = $value['service_id'];
						$ser_added = "ser_added$serv_id";
						$serv_cost = 0;
						if(!empty($$ser_added)){ 
					?>
							<tr>
								<td class="a-left" colspan="2">
									<table>
										<tr>
											<td colspan="2">Added : </td>
										</tr>
										<?php 
											$t_ttcost = 0;
											$stt = 1;
											foreach($$ser_added as $temp){
												if(!empty($temp['name'])){
													echo "<tr><td class='left30'>".$temp['name']."</td>";
													echo "<td class='a-right'>$".$temp['cost']."</td></tr>";
													$t_ttcost += $temp['cost'] ;
												}
												$stt++;
											}
										?> 
									</table>
								</td>
							</tr>
					<?php 
							$serv_cost = $serv_cost + $cost + $t_ttcost ;
						}else{
							$serv_cost = $serv_cost + $cost ;
						}
										
					?>
						<tr>
							<td colspan="2"><hr /><hr /></td>
						</tr>
					<?
						$total_cost = $total_cost + $serv_cost;
					}
						?>
					
					<tr>
						<td class="a-left bold" >Total </td>
						<td class="a-right total_price bold"><?php echo to_currency($total_cost) ; ?></td>
					</tr>
				<?php 	
				}
				?>
			</table>	
		</td>
		<tr>
			<td class="border a-left">
				<p>Term & Condition</p>
			</td>
		</tr>
		
		<tr>
			<td class="border a-left">
				<table>
					<tr>
						<td class="a-left term_and_condition">
							<?php 
								$inc = 1;
								foreach ($service_term as $term){ 
								
								?>
								<p style="padding-left:10px;">
									<?php 
										if(!empty($term)){
											echo $inc.". ".$term;							}
									?>
								</p>
							<?php 
								$inc++;	
								} 
							?>
						</td>
					</tr>
					<tr>
						<td class="a-left hr_td"><hr style="float:left;margin-left:10px;width:150px;" /></td>
					</tr>
					<tr>
						<td class="a-left">Sales - Repairs</td>
					</tr>
					<tr>
						<td class="a-left">Mobile phone & Laptop</td>
					</tr>
					<tr>
						<td class="a-left">info@astore.net.au - www.astore.net.au</td>
					</tr>
				</table>
			</td>
		</tr>
	</table>
</center>
</body>
</html>
<?php $this->load->view("partial/footer"); ?>